package com.imy.rootserver.gesture;

import android.util.Log;
import android.view.MotionEvent;

import java.util.HashMap;


public class EventSendThread implements Runnable {
    public MotionEvent event;
    private InteractionController mInteractionController;
    public static HashMap<Integer, EventSendThread> mCache = new HashMap<>();



    public static EventSendThread obtain(MotionEvent event, int id,
        InteractionController interactionController) {
        EventSendThread eventSendThread = mCache.get(id);
        if (eventSendThread == null) {
            eventSendThread = new EventSendThread(event,interactionController);
            mCache.put(id, eventSendThread);
        } else {
            eventSendThread.event = event;

        }
        return eventSendThread;
    }

    public EventSendThread(MotionEvent point, InteractionController interactionController) {
        event = point;
        this.mInteractionController =interactionController;
    }

    @Override
    public void run() {
        Log.i("EventSendThread"," 执行命令" +event);
        boolean b = mInteractionController.injectEventSync(event);

    }
}
